<% @main_header = "#{link_to('Ptrack:', '/')} New Project Pattern" %>
<% @title = 'Create A New Project Pattern' %>
<h2>Create A New Project Pattern</h2>

<%= error_messages_for 'pattern',:header_message=>nil,:class=>'error' %>
<%= display_messages_for_all %>

<% form_for @pattern, :url => '/patterns/create' do |f| %>
  <table>
    <tr>
      <td><%= f.label :title,'Project Pattern Title:' %></td>
      <td><%= f.text_field :title %></td>
    </tr>
    <tr>
      <td><%= label_tag 'project_id', 'Copy From Existing Project:' %></td>
      <td><%= select('project', 'project_id', Project.find(:all).collect {|p| [ p.name, p.id ] }, {:selected=>@project_id.to_i,:include_blank => true }, :onchange => remote_function(
            :url => {:controller=>:patterns ,:action => :show_project_phases},
            :update => "pattern_phases",
            :with => "'id=' + this.value")) %></td>
    </tr>
    <tr>
      <td><%= label_tag 'pattern_phases', 'Phases:' %></td>
      <td> <ul id="pattern_phases">
          <%= render :partial => 'phase_input', :locals=>{:phases=>@patterns_phases} %>
        </ul>

        <%= sortable_element 'pattern_phases',
          :complete => visual_effect(:highlight, 'pattern_phases')
      %>

        <%= link_to_remote  image_tag('/images/add.png') + "Add A Phase" ,
          :update => "pattern_phases",
          :url => {:action => "add_phase" },
          :position => "bottom"
      %></td>
    </tr>
    <tr>
      <td></td><td><%= submit_tag 'Create' %> </td>
    </tr>
  </table>
<% end %>
<%= link_to 'Back', patterns_path %>
